package okl.lab.namesFilter.service
{
	import mx.collections.ArrayCollection;
	import mx.core.Application;
	import mx.rpc.IResponder;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	
	import okl.lab.namesFilter.model.AppModel;
	import okl.lab.namesFilter.service.utils.MockServiceUtils;
	import okl.lab.namesFilter.service.utils.ServiceUtils;
	import okl.lab.namesFilter.tests.utils.TestDataGenerator;
	
	import org.robotlegs.mvcs.Actor;

	
	/**
	 * 	Mocks users service. 
	 * 	@see okl.lab.namesFilter.service.TestDataGenerator
	 *	@author "oleksandr.kulinchenko@gmail.com"
	 */
	public class MockUserService extends Actor implements IUsersService, IResponder
	{
		[Inject]public var model:AppModel;
		public function MockUserService()
		{
			super();
		}
		
		public function getUsers():void
		{
			var count:Number = model.settings.mockedUsersCount;
			var expectedResult:ArrayCollection = new ArrayCollection(TestDataGenerator.generateUsers(count));
			MockServiceUtils.createToken(expectedResult).addResponder(this);
			
		}

		public function result(data:Object):void{
			model.users=data.result;
		}
		

		public function fault(info:Object):void{
			ServiceUtils.faultHandler(info as FaultEvent);
		}

	}
}